import { Image } from '@tarojs/components';
import ImageConstant from '@/constant/ImageConstant';

interface IProps {
  src?: string;
  className?: string;
  onClick?: Function;
  mode?: string;
}

export default function ImageComp(props: IProps) {
  const {
    src = ImageConstant.DEFAULT_IMG,
    className,
    onClick,
    mode = 'aspectFill'
  } = props;

  const handleClick = () => {
    onClick && onClick();
  };

  return <Image
    src={ `${ ImageConstant.SERVER_ROOT }${ src }` }
    className={ className }
    mode={ mode as any }
    onClick={ handleClick }
  />;
}